#include "config.h"
-#include "gtkshortcutcontroller.h"
+#include "gtkshortcutcontrollerprivate.h"
#include "gtkeventcontrollerprivate.h"
#include "gtkbindings.h"
struct _GtkShortcutController
{
GtkEventController parent_instance;
+
+ guint run_class : 1;
};
struct _GtkShortcutControllerClass
const GSList *l;
widget = gtk_event_controller_get_widget (controller);
- if (event_type == GDK_KEY_PRESS ||
- event_type == GDK_KEY_RELEASE)
- {
- if (gtk_bindings_activate_event (G_OBJECT (widget), event))
- return TRUE;
- }
- for (l = gtk_widget_class_get_shortcuts (GTK_WIDGET_GET_CLASS (widget)); l; l = l->next)
+ if (self->run_class)
{
- if (gtk_shortcut_controller_trigger_shortcut (self, l->data, event))
- return TRUE;
+ if (event_type == GDK_KEY_PRESS ||
+ event_type == GDK_KEY_RELEASE)
+ {
+ if (gtk_bindings_activate_event (G_OBJECT (widget), event))
+ return TRUE;
+ }
+
+ for (l = gtk_widget_class_get_shortcuts (GTK_WIDGET_GET_CLASS (widget)); l; l = l->next)
+ {
+ if (gtk_shortcut_controller_trigger_shortcut (self, l->data, event))
+ return TRUE;
+ }
}
return FALSE;
return g_object_new (GTK_TYPE_SHORTCUT_CONTROLLER,
NULL);
}
+
+void
+gtk_shortcut_controller_set_run_class (GtkShortcutController *controller,
+ gboolean run_class)
+{
+ controller->run_class = run_class;
+}
--- /dev/null
+/*
+ * Copyright © 2018 Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Benjamin Otte <otte@gnome.org>
+ */
+
+#ifndef __GTK_SHORTCUT_CONTROLLER_PRIVATE_H__
+#define __GTK_SHORTCUT_CONTROLLER_PRIVATE_H__
+
+#include "gtkshortcutcontroller.h"
+
+void gtk_shortcut_controller_set_run_class (GtkShortcutController *controller,
+ gboolean run_class);
+
+#endif /* __GTK_SHORTCUT_CONTROLLER_H__ */
#include "gtkscrollable.h"
#include "gtksettingsprivate.h"
#include "gtkshortcut.h"
-#include "gtkshortcutcontroller.h"
+#include "gtkshortcutcontrollerprivate.h"
#include "gtkshortcuttrigger.h"
#include "gtksizegroup-private.h"
#include "gtksnapshotprivate.h"
GtkWidget *widget = GTK_WIDGET (instance);
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GType layout_manager_type;
+ GtkEventController *controller;
widget->priv = priv;
if (layout_manager_type != G_TYPE_INVALID)
gtk_widget_set_layout_manager (widget, g_object_new (layout_manager_type, NULL));
- gtk_widget_add_controller (widget, gtk_shortcut_controller_new ());
+ controller = gtk_shortcut_controller_new ();
+ gtk_shortcut_controller_set_run_class (GTK_SHORTCUT_CONTROLLER (controller), TRUE);
+ gtk_widget_add_controller (widget, controller);
}
/**